package com.topscomm.gpm.controller;

import com.topscomm.gpm.service.impl.GpmGanttService;
import com.topscomm.tap.common.DatacodeCache;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.vo.ResponseResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 甘特图接口
 * @author liwanpeng
 * @version 1.0
 * @description: TODO
 * @date 2021/1/23 14:28
 */
@RestController
@RequestMapping("/sd/gantt")
public class GpmGanttController {
    @Autowired
    private GpmGanttService gpmGanttService;
    /**
     * @description: 根据项目id获取甘特图需要的信息
     * @param: param
     * @return: com.topscomm.pub.vo.ResponseResult<java.lang.Object>
     * @author Administrator
     * @date: 2021/1/23 14:33
     */
    @RequestMapping("/getGanttInfoByProjectId")
    public ResponseResult<Object> getGanttInfoByProjectId(@RequestParam(required = false)Map<String,Object> param){
        ResponseResult<Object> result = gpmGanttService.getGanttInfo(ConvertUtil.convertToLong(param.get("projectId")));
        return result;
    }
    
	/**
	 * datacodelist方法
	 *
	 * @description:
	 * @param paraMap
	 * @return
	 * @author: hdy
	 * @date: 2021年12月21
	 * @modify:
	 */
	@GetMapping(value = "/dataCodeList")
	public ResponseResult<Object> dataCodeList(@RequestParam(required = false) Map<String, Object> paraMap) {
		Map<String,Object> codeMap = new HashMap<>();
		DatacodeCache datacodeCache = new DatacodeCache();
		List<Map<String, Object>> ganttScalesTypeList = datacodeCache.getCodeListMap("GpmGanttScalesType", "", "sortcode");
		codeMap.put("ganttScalesTypeList", ganttScalesTypeList);
		return ResponseResult.ok(codeMap);
	}
}
